package com.lagou.task1.work3;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class MapTest {

    public static void main(String[] args) {
        Map<String,Integer> map = new HashMap<>();
        String str = "123,456,789,123,456";
        String[] strings = str.split(",");
        for (String s : strings) {
            if (map.containsKey(s)){
                Integer integer = map.get(s);
                integer++;
                map.put(s,integer);
            }else {
                map.put(s,1);
            }
        }
        Set<String> strings1 = map.keySet();
        for (String s : strings1) {
            System.out.println(s + "出现的次数为" + map.get(s));
        }
    }
}
